var t = getApp();

Page({
    data: {
        coupon_id: ""
    },
    onLoad: function(t) {
        this.setData({
            coupon_id: t.id
        }), this.getData();
    },
    fuzhi: function() {},
    selectedcoupon: function(o) {
        var a = o.currentTarget.dataset.item, e = o.currentTarget.dataset.id, n = this, i = t.getNetAddresss("coupon.member-coupon.get-coupon");
        i += "&coupon_id=" + a.id, t._getNetWork({
            url: i,
            success: function(t) {
                var o = t.data;
                1 == o.result ? wx.showToast({
                    title: "领取成功",
                    icon: "none",
                    duration: 1e3,
                    success: function() {
                        1 == n.data.goods.length && setTimeout(function() {
                            wx.navigateTo({
                                url: "/packageA/detail_v2/detail_v2?id=" + e
                            });
                        }, 500);
                    }
                }) : o.data.reason ? wx.showModal({
                    title: o.msg,
                    content: o.data.reason,
                    showCancel: !1
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareTimeline: function() {
        return {
            title: this.data.goods[0].title + "\r日常价：" + this.data.goods[0].price + "\r券后价：" + this.data.goods[0].deduct_price,
            query: "id=".concat(this.data.coupon_id)
        };
    },
    onShareAppMessage: function() {
        return {
            title: this.data.goods[0].title + "\r日常价：" + this.data.goods[0].price + "\r券后价：" + this.data.goods[0].deduct_price,
            path: "/packageE/team_sell/getCouponShare/getCouponShare?id=" + this.data.coupon_id
        };
    },
    toDetail: function(t) {
        var o = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + o
        });
    },
    getData: function() {
        var o = this, a = t.getNetAddresss("coupon.member-coupon.getGoodsCouponByCouponId");
        t._getNetWork({
            url: a,
            data: {
                coupon_id: o.data.coupon_id
            },
            success: function(t) {
                var a = t.data;
                console.log(a), 1 == a.result && o.setData({
                    datas: a.data,
                    goods: a.data.goods,
                    icon: a.data.icon,
                    time_start: a.data.time_start.split(" ")[0],
                    time_end: a.data.time_end.split(" ")[0]
                });
            },
            fail: function(t) {
                wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                });
            }
        });
    }
});